package com.xnyzc.lhy.common.util;

import java.math.BigDecimal;

/**
 * @Author: huxuekuo
 * @Date: 2019-08-22 14:12
 * @Description:
 */
public class NumberToChn {
    private static String CHN_NUMBER[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
    /**
     * 阿拉伯数字转换为中文数字的核心算法实现。
     * @return
     */
    public static String NumberToChn(String num) {
        StringBuffer returnStr = new StringBuffer();
        for (int i = 0; i < num.length(); i++) {
            String substring = num.substring(i, i + 1);
            returnStr.append(CHN_NUMBER[Integer.valueOf(substring).intValue()]);
        }
        return returnStr.toString();
    }

    /**
     * 将分转换成元
     * @return
     */
    public static BigDecimal moneyFenToYuan(Long num){
        long yuan = num/100;
        long fen = num%100;
        String newNum = yuan+"."+fen;
        return new BigDecimal(newNum);
    }

    public static void main(String[] args) {
        String s = NumberToChn("");
        System.out.println(s);

    }
}
